package smsystem;


import java.io.Serializable;

public class Member implements Serializable {

	private static final long serialVersionUID = 1L;

	protected String name;
	protected int age;
	protected String number;
	protected String level;

	public Member() {
	}

	public Member(String csv) {
		String[] items = csv.split(",");
		this.name = items[0];
		this.age = Integer.parseInt(items[1]);
		this.number = items[2];
		this.level = items[3];
	}

	@Override
	public String toString() {
		return name + "," + age + "," + number + "," + level;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + ((number == null) ? 0 : number.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((level == null) ? 0 : level.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Member other = (Member) obj;
		if (age != other.age)
			return false;
		if (number == null) {
			if (other.number != null)
				return false;
		} else if (!number.equals(other.number))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (level != other.level){
			if(other.level != null)
				return false;
		}else if (!level.equals(other.level))
			return false;
		return true;

	}

	public String getName() {
		return name;
	}

	public int getAge() {

		return age;
	}

	public String getNumber() {
		return number;
	}

	public String getLevel() {
		return level;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAge(int age) {
		if (this.age > 19 && this.age < 60) {
			this.age = age;
		} else {
			this.age = 20;
		}
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public void setLevel(String level) {
		this.level = level;
	}

}